//
//  LicensePlateContentViewController.m
//  XinKaiFa55like
//
//  Created by junseek on 2017/4/8.
//  Copyright © 2017年 55like lj. All rights reserved.
//

#import "LicensePlateContentViewController.h"
#import "RHTableView.h"
#import "MessageEvaluationTableViewCell.h"
#import "MessageCircleFriendsTableViewCell.h"
#import "TextKeyboardView.h"
#import "SelectWebUrlViewController.h"
#import <WebKit/WebKit.h>
#import "WebImagesViewController.h"

@interface LicensePlateContentViewController ()<MessageCircleFriendsTableViewCellDelegate,MessageEvaluationTableViewCellDelegate,UIAlertViewDelegate,WKNavigationDelegate>{
//    RHTableView *tableViewLeft;
    NSInteger ftempCircleFriends;
//    NSIndexPath *circleFriendsIndexPath;
//    TextKeyboardView *textKeyboard;
    WKWebView *webContentView;
    NSString *strTempUrl;
    BOOL boolPopRefresh;
//    UIView *viewHeaderBG;
    float f_tempKeyBoard;
    UIButton *btnCollection;
    
    NSMutableArray *arrayImages;
    
    
    
}


@end

@implementation LicensePlateContentViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
//    //注册监听键盘事件
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
//    [webContentView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
//    [webContentView.scrollView removeObserver:self forKeyPath:@"contentSize" context:nil];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initTabelViews];
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        [self loadTableData];
//    });
}
-(void)initTabelViews{
    arrayImages=[NSMutableArray new];
    [self rightButton:nil image:@"headfx" sel:@selector(rightBUttonClicked)];
    self.navrightButton.frame=CGRectMake(kScreenWidth-44, 20, 44, 44);
    btnCollection=[RHMethods buttonWithFrame:CGRectMake(kScreenWidth-88, 20, 44, 44) title:nil image:@"headsc" bgimage:nil];
    [btnCollection setImage:[UIImage imageNamed:@"headscon"] forState:UIControlStateSelected];
    [btnCollection addTarget:self action:@selector(collectionButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.navView addSubview:btnCollection];
    btnCollection.selected=![[self.otherInfo valueForJSONStrKey:@"iscollection"] isEqualToString:@"0"];//iscollection        int            是否已收藏（0.未收藏 02.09新增）
    
//    
//    tableViewLeft=[[RHTableView alloc]initWithFrame:CGRectMake(0, kTopHeight, kScreenWidth, kContentHeight-44)];
//    [tableViewLeft showRefresh:YES LoadMore:YES];
//    tableViewLeft.delegate = self;
//    tableViewLeft.dataSource = self;
//    tableViewLeft.strNullTitle=@"  ";
//    [tableViewLeft setBackgroundColor:rgbGray];
//    [tableViewLeft setSeparatorStyle:UITableViewCellSeparatorStyleNone];
//    [self.view addSubview:tableViewLeft];
//    [tableViewLeft setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
    
//    viewHeaderBG=[[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
//    UIView *viewT=[[UIView alloc] initWithFrame:CGRectMake(0, 10, kScreenWidth, 30)];
//    viewT.backgroundColor=[UIColor whiteColor];
//    UIView *lineV=[RHMethods lineViewWithFrame:CGRectMake(10, 8, 2, 15)];
//    lineV.backgroundColor=rgbpublicColor;
//    [viewT addSubview:lineV];
//    [viewT addSubview:[RHMethods labelWithFrame:CGRectMake(18, 5, 0, 20) font:fontTitle color:rgbTitleColor text:@"最新评论"]];
//    viewT.autoresizingMask=UIViewAutoresizingFlexibleTopMargin;
//    [viewHeaderBG addSubview:viewT];
    webContentView=[[WKWebView alloc] initWithFrame:CGRectMake(0, kTopHeight, kScreenWidth, kContentHeight-44)];
//    webContentView.scalesPageToFit = YES;//自动对页面进行缩放以适应屏幕
    webContentView.navigationDelegate=self;
    strTempUrl=[self.otherInfo valueForJSONStrKey:@"url"];
    if (strTempUrl.length>4) {
        strTempUrl= [[[strTempUrl lowercaseString] substringToIndex:4] isEqualToString:@"http"]?strTempUrl:[NSString stringWithFormat:@"http://%@",strTempUrl];
    }
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:strTempUrl]];
    [webContentView loadRequest:request];
//    webContentView.scrollView.scrollEnabled=NO;
    [self.view addSubview:webContentView];
//    [tableViewLeft setTableHeaderView:viewHeaderBG];
    
//    textKeyboard=[[TextKeyboardView alloc]init];
//    textKeyboard.frame=CGRectMake(0, kScreenHeight, kScreenWidth, 300);
//    textKeyboard.selfView_Y=kScreenHeight;
//    [self.view addSubview:textKeyboard];
    
    
    UIView *viewBottom=[[UIView alloc] initWithFrame:CGRectMake(0, YH(webContentView), kScreenWidth, 44)];
    viewBottom.backgroundColor=RGBCOLOR(56, 58, 75);
    viewBottom.autoresizingMask=UIViewAutoresizingFlexibleTopMargin;
    [self.view addSubview:viewBottom];
    
    UIButton *btnLeft=[RHMethods buttonWithFrame:CGRectMake(0, 0, kScreenWidth, 44) title:@"  电话咨询" image:@"phoneicon070116" bgimage:nil];
    [btnLeft addTarget:self action:@selector(telButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [btnLeft setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [viewBottom addSubview:btnLeft];
//    
//    UIButton *btnRight=[RHMethods buttonWithFrame:CGRectMake(kScreenWidth/2, 0, kScreenWidth/2, 44) title:@"  参与评论" image:@"tiwenicon070116" bgimage:nil];
//    [btnRight addTarget:self action:@selector(twButtonClicked) forControlEvents:UIControlEventTouchUpInside];
//    [btnRight setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [viewBottom addSubview:btnRight];
//    
//    UIView *viewLine=[[UIView alloc] initWithFrame:CGRectMake(kScreenWidth/2, 12, 1, 20)];
//    viewLine.backgroundColor=[UIColor whiteColor];
//    [viewBottom addSubview:viewLine];
    
}

-(void)loadTableData{
//    krequestParam
//    [dictparam setValue:@"%@" forKey:@"page"];
//    [dictparam setValue:@"20" forKey:@"pagesize"];
//    [dictparam setValue:[self.otherInfo valueForJSONStrKey:@"id"] forKey:@"lid"];
//    tableViewLeft.urlString=[NSString stringWithFormat:@"%@%@",XKFV3homesproductcomment,dictparam.wgetParamStr];
//    [tableViewLeft refresh];
}
#pragma mark button
-(void)backButtonClicked:(id)sender{
    [webContentView stopLoading];
    webContentView.navigationDelegate=nil;
    webContentView=nil;
    [super backButtonClicked:sender];
}
-(void)collectionButtonClicked{
    //收藏
    btnCollection.selected=!btnCollection.selected;
    NSString *urls=[NSString stringWithFormat:XKFnewscollection,[[Utility Share] userId],[[Utility Share] userToken],[self.otherInfo valueForJSONStrKey:@"id"],btnCollection.selected?@"1":@"0"];
    if ([self.userInfo isEqualToString:@"Insurance"]) {
        urls=[NSString stringWithFormat:XKFV3homescollection,[[Utility Share] userId],[[Utility Share] userToken],[self.otherInfo valueForJSONStrKey:@"id"],btnCollection.selected?@"1":@"0"];
    }
    [NetEngine createGetAction_LJ:urls onCompletion:^(id resData, BOOL isCache) {
        if ([[resData valueForJSONStrKey:@"status"] isEqualToString:@"200"]) {
            [self backRefreshData];
        }else{
            btnCollection.selected=!btnCollection.selected;
            [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
        }
    }];
    
}
-(void)rightBUttonClicked{
    //分享
    /*
     {
     "src": "/upload/tumour/1/1478856592.jpg",
     "title": "出现肿瘤别慌",
     "descr": "出现肿瘤别慌",
     "url": "http://www.jiusheng.com/wappage/news_detail?id=1"
     }
     
     */
    NSDictionary *dct=[self.otherInfo objectForJSONKey:@"sharedata"];
    NSMutableDictionary *dic=[NSMutableDictionary new];
    [dic setValue:[dct valueForJSONStrKey:@"pic"] forKey:@"src"];
    [dic setValue:[dct valueForJSONStrKey:@"title"] forKey:@"title"];
    [dic setValue:[dct valueForJSONStrKey:@"content"] forKey:@"descr"];
    [dic setValue:[dct valueForJSONStrKey:@"url"] forKey:@"url"];
    
    [[Utility Share] showShareData:dic suc:^(NSInteger NoSuc) {
        if (NoSuc==1) {
            [SVProgressHUD showSuccessWithStatus:@"分享成功！"];
            [self shareStatistics];
        }
    }];
}
-(void)shareStatistics{
    krequestParam
    if ([self.userInfo isEqualToString:@"Insurance"]) {
        [dictparam setValue:@"1" forKey:@"type"];
    }else{
        [dictparam setValue:@"2" forKey:@"type"];
    }
    [dictparam setValue:[self.otherInfo valueForJSONStrKey:@"id"] forKey:@"objid"];
    [NetEngine createGetAction_LJ:[NSString stringWithFormat:@"%@%@",XKFV3usershare,dictparam.wgetParamStr] onCompletion:^(id resData, BOOL isCache) {
        //        if ([[resData valueForJSONStrKey:@"status"] isEqualToString:@"200"]) {
        //
        //        }else{
        //        }
    }];
}
#pragma mrak button
-(void)telButtonClicked{
    DLog(@"\n\n\n拨号：%@\n\n\n",[self.otherInfo valueForJSONStrKey:@"telephone"]);
    UIWebView*callWebview =[[UIWebView alloc] init];
    NSString *telUrl = [NSString stringWithFormat:@"tel:%@",[self.otherInfo valueForJSONStrKey:@"telephone"]];
    NSURL *telURL =[NSURL URLWithString:telUrl];// 貌似tel:// 或者 tel: 都行
    [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
    //记得添加到view上
    [self.view addSubview:callWebview];
}
-(void)twButtonClicked{
//    circleFriendsIndexPath=nil;
//    textKeyboard.textSend.placeholder=@"参与评论...";
//    __weak LicensePlateContentViewController * viewC1=self;
//    [textKeyboard setValueForDictionary:nil indexPath:nil sendText:^(NSDictionary *dict, NSIndexPath *indexPath, NSString *txtSend) {
//        [viewC1 sendEvaluationData:txtSend selectIndex:nil];
//        
//    }];
}
//分离URL参数
-(NSMutableDictionary *)dicSeparatedUrl:(NSString *)strurl{
    //获取问号的位置，问号后是参数列表
    NSRange range = [strurl rangeOfString:@"?"];
    NSLog(@"参数列表开始的位置：%d", (int)range.location);
    
    //获取参数列表
    NSString *propertys = [strurl substringFromIndex:(int)(range.location+1)];
    NSLog(@"截取的参数列表：%@", propertys);
    
    //进行字符串的拆分，通过&来拆分，把每个参数分开
    NSArray *subArray = [propertys componentsSeparatedByString:@"&"];
    NSLog(@"把每个参数列表进行拆分，返回为数组：n%@", subArray);
    
    //把subArray转换为字典
    //tempDic中存放一个URL中转换的键值对
    NSMutableDictionary *tempDic = [NSMutableDictionary dictionaryWithCapacity:4];
    
    for (int j = 0 ; j < subArray.count; j++)
    {
        if ([subArray[j] notEmptyOrNull]) {
            //在通过=拆分键和值
            NSArray *dicArray = [subArray[j] componentsSeparatedByString:@"="];
            if ([dicArray count]>1) {
                //给字典加入元素
                [tempDic setObject:dicArray[1] forKey:dicArray[0]];
            }else if([dicArray count]){
                [tempDic setObject:@"" forKey:dicArray[0]];
            }
        }
    }
    NSLog(@"打印参数列表生成的字典：n%@", tempDic);
    
    return tempDic;
}
//#pragma mark -
//#pragma mark UIWebViewDelegate
//
//- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
//    strTempUrl= [request.URL absoluteString];
//    if ( [strTempUrl rangeOfString:@"&action=userCard"].length>0) {
//        //牌照详情-查看个人名片
//        NSDictionary *dicUser = [self dicSeparatedUrl:[strTempUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//        NSMutableDictionary *dicCard=[NSMutableDictionary new];
//        [dicCard setValue:strTempUrl forKey:@"url"];
//        [dicCard setValue:[dicUser valueForJSONStrKey:@"id"] forKey:@"uid"];
//        [dicCard setValue:NSStringFromClass([self class]) forKey:@"controller"];
//        [self pushController:[SelectWebUrlViewController class] withInfo:@"shareCard" withTitle:@" " withOther:dicCard];
//        return NO;
//    }
//    
//    DLog(@"request.URL:%@",strTempUrl);
//    return YES;
//}
//- (void)webViewDidStartLoad:(UIWebView *)webView {
//    DLog(@"开始web")
//}
//- (void)webViewDidFinishLoad:(UIWebView *)webView {
//    
//    CGFloat webViewHeight =[[webContentView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"]floatValue];//webContentView.scrollView.contentSize.height;//
//    CGFloat webViewHeight2= [[webContentView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"]floatValue];
//    
//    DLog(@"完成web:%f____%f___%f",webContentView.scrollView.contentSize.height,webViewHeight,webViewHeight2)
//    CGRect newFrame = webContentView.frame;
//    newFrame.size.height= webViewHeight>webViewHeight2?webViewHeight:webViewHeight2;
//    webContentView.frame= newFrame;
//    viewHeaderBG.frameHeight=H(webContentView)+40;
//    [tableViewLeft setTableHeaderView:viewHeaderBG];
//}
//- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
//    DLog(@"webError:%@",error)
//}
#pragma mark - WKNavigationDelegate
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    strTempUrl= [navigationAction.request.URL absoluteString];
    if ( [strTempUrl rangeOfString:@"&action=userCard"].length>0) {
        //牌照详情-查看个人名片
        NSDictionary *dicUser = [self dicSeparatedUrl:[strTempUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        NSMutableDictionary *dicCard=[NSMutableDictionary new];
        [dicCard setValue:strTempUrl forKey:@"url"];
        [dicCard setValue:[dicUser valueForJSONStrKey:@"id"] forKey:@"uid"];
        [dicCard setValue:NSStringFromClass([self class]) forKey:@"controller"];
        [self pushController:[SelectWebUrlViewController class] withInfo:@"shareCard" withTitle:@" " withOther:dicCard];
       decisionHandler(WKNavigationActionPolicyCancel);
        return;
    }
    NSString *requestString = [[navigationAction.request URL] absoluteString];
    //hasPrefix 判断创建的字符串内容是否以pic:字符开始
    if ([requestString hasPrefix:@"myweb:imageClick:"]) {
        NSString *imageUrl = [requestString substringFromIndex:@"myweb:imageClick:".length];
        NSInteger index_img=0;
        NSMutableArray *array=[[NSMutableArray alloc] init];
        for (int i=0 ; i<[arrayImages count];i++) {
            NSString *strImg =[arrayImages objectAtIndex:i];
            if ([strImg isEqualToString:imageUrl]) {
                index_img=i;
            }
            NSMutableDictionary *dt=[[NSMutableDictionary alloc] init];
            [dt setValue:strImg forKey:@"url"];
            [array addObject:dt];
        }
        [self pushController:[WebImagesViewController class]
                                         withInfo:@"myWebView"
                                        withTitle:@"查看"
                                        withOther:@{@"lookImages":array,
                                                    @"lookSelectIndex":[NSString stringWithFormat:@"%ld",(long)index_img]}];
        
        decisionHandler(WKNavigationActionPolicyCancel);
        return;
    }
    
//    NSURL *URL = navigationAction.request.URL;
//    NSString *scheme = [URL scheme];
//    if ([scheme isEqualToString:@"haleyaction"]) {
//        [self handleCustomAction:URL];
//        decisionHandler(WKNavigationActionPolicyCancel);
//        return;
//    }
    decisionHandler(WKNavigationActionPolicyAllow);
}

// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
    DLog(@"web开始加载：%@",[webView.URL absoluteString]);    
    [SVProgressHUD showWithStatus:@"加载中"];
}
// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    //js方法遍历图片添加点击事件 返回图片点击个数
    static  NSString * const jsGetImages =
    @"function getImages(){\
    var image_url=\"\";\
    var index_click=0;\
    var objs = document.getElementsByTagName(\"img\");\
    for(var i=0;i<objs.length;i++){\
    if(objs[i].getAttribute(\"data-src\")){\
    if(image_url){\
    image_url=image_url+\"__zkwap__\"+objs[i].getAttribute(\"data-src\");\
    }else{\
    image_url=objs[i].getAttribute(\"data-src\");\
    };\
    index_click++;\
    objs[i].onclick=function(){\
    document.location=\"myweb:imageClick:\"+this.getAttribute(\"data-src\");;\
    };\
    };\
    };\
    return image_url;\
    };getImages();";
    
    
    //
    /// jsStr为要执行的js代码，字符串形式
    [webView evaluateJavaScript:jsGetImages completionHandler:^(id _Nullable resurlt, NSError * _Nullable error) {
        // 执行结果回调
        DLog(@"执行结果回调:%@",resurlt);
        [arrayImages removeAllObjects];
        if ([resurlt notEmptyOrNull]) {
            [arrayImages addObjectsFromArray:[resurlt componentsSeparatedByString:@"__zkwap__"]];
        }
        
    }];
    [SVProgressHUD dismiss];
//     [self loadTableData];
}

// 页面加载失败时调用
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation{
    [SVProgressHUD showImage:nil status:@"数据加载失败！"];
}
//- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation
//{
//    [webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
//        //获取页面高度
//        double webViewHeight = [result doubleValue];
//    }];
//    [webView evaluateJavaScript:@"document.body.offsetHeight" completionHandler:^(id _Nullable result,NSError * _Nullable error) {
//        //获取页面高度，并重置webview的frame
//        _webViewHeight = [resultdoubleValue];
//        CGRect frame =webView.frame;
//        frame.size.height =_webViewHeight;
//        webView.frame = frame;
//    }];
//}

//- (void)observeValueForKeyPath:(NSString *)keyPath
//                      ofObject:(id)object
//                        change:(NSDictionary *)change
//                       context:(void *)context
//{
//    if (object == webContentView.scrollView && [keyPath isEqual:@"contentSize"]) {
//        // we are here because the contentSize of the WebView's scrollview changed.
//        UIScrollView *scrollView = webContentView.scrollView;
////        DLog(@"New contentSize: %f x %f", scrollView.contentSize.width, scrollView.contentSize.height);
//        if (webContentView.frameHeight != scrollView.contentSize.height) {
//            webContentView.frameHeight= scrollView.contentSize.height;
//            viewHeaderBG.frameHeight=H(webContentView)+40;
//            [tableViewLeft setTableHeaderView:viewHeaderBG];
//            DLog(@"set frameHeight:%f",scrollView.contentSize.height)
//        }
//
//    }
//}
//#pragma mark tableView
//#pragma mark UITableViewDataSource,UITableViewDelegate
//-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
//    if (tableView==tableViewLeft) {
//        return tableViewLeft.dataArray.count;
//    }
//    return 1;
//}
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    if (tableView==tableViewLeft){
//        NSDictionary *dic=[tableViewLeft.dataArray objectAtIndex:section];
//        return [[dic objectForJSONKey:@"comment"] count]+1;
//    }
//    return 0;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if (tableView==tableViewLeft){
//        if (indexPath.row==0) {
//            NSDictionary *dic=[tableViewLeft.dataArray objectAtIndex:indexPath.section];
//            NSString *identifier = [NSString stringWithFormat:@"identifier_left_%@",[dic valueForJSONStrKey:@"id"]].md5;//@"CricleFriends";
//            MessageCircleFriendsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
//            if (!cell) {
//                cell = [[MessageCircleFriendsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
//            }
//            ftempCircleFriends= [cell setValueForDictionary:dic indexPath:indexPath type:@"noImage"];
//        }else{
//            [self tableView:tableViewLeft cellForRowAtIndexPath:indexPath];
//        }
//        return ftempCircleFriends;
//    }
//    return 0;
//}
//
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if (tableView==tableViewLeft){
//        if (indexPath.row==0) {
//            NSDictionary *dic=[tableViewLeft.dataArray objectAtIndex:indexPath.section];
//            NSString *identifier = [NSString stringWithFormat:@"identifier_left_%@",[dic valueForJSONStrKey:@"id"]].md5;//@"CricleFriends";
//            
//            MessageCircleFriendsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
//            if (!cell) {
//                cell = [[MessageCircleFriendsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
//            }
//            cell.delegate=self;
//            ftempCircleFriends= [cell setValueForDictionary:dic indexPath:indexPath type:@"hidden"];
//            return cell;
//        }else{
//            NSDictionary *dic=[tableViewLeft.dataArray objectAtIndex:indexPath.section];
//            static NSString *identifier3 = @"identifier_left_Evaluation";//
//            MessageEvaluationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier3];
//            if (!cell) {
//                cell = [[MessageEvaluationTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier3];
//            }
//            cell.delegate=self;
//            ftempCircleFriends= [cell setValueForDictionary:[[dic objectForJSONKey:@"comment"] objectAtIndex:indexPath.row-1] indexPath:indexPath EvaluationCount:[[dic objectForJSONKey:@"comment"] count] ];////
//            return cell;
//            
//        }
//        
//    }
//    return nil;
//}
//-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//}
//
//-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
//    [self.view endEditing:YES];
//}

//#pragma mark MessageCircleFriendsTableViewCellDelegate
//-(void)selectEvaluation:(MessageCircleFriendsTableViewCell *)sview object:(id)dic index:(NSIndexPath *)indexPath{
//    
//    //朋友圈评论
//    circleFriendsIndexPath=indexPath;
//    textKeyboard.textSend.placeholder=@"说点什么...";
//    __weak LicensePlateContentViewController * viewC1=self;
//    [textKeyboard setValueForDictionary:nil indexPath:circleFriendsIndexPath sendText:^(NSDictionary *dict, NSIndexPath *indexPath, NSString *txtSend) {
//        [viewC1 sendEvaluationData:txtSend selectIndex:indexPath];
//        
//    }];
//    
//    
//}
//-(void)selectPraise:(MessageCircleFriendsTableViewCell *)sview object:(id)dic index:(NSIndexPath *)indexPath{
//    [self.view endEditing:YES];
//    //朋友圈点赞
//    
//    circleFriendsIndexPath=indexPath;
//    //    NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
//    //    [dict setValue:[[Utility Share] userId] forKey:@"uid"];
//    //    [dict setValue:[[Utility Share] userToken] forKey:@"token"];
//    //    [dict setValue:[dic valueForJSONStrKey:@"id"] forKey:@"id"];
//    //
//    //
//    //    [NetEngine createPostAction:YDcircletalkPraise withParams:dict onCompletion:^(id resData, BOOL isCache) {
//    //        if ([[resData objectForJSONKey:@"status"] isEqualToString:@"200"]) {
//    //            [SVProgressHUD showSuccessWithStatus:@"点赞成功！"];
//    //
//    //            [tableCircleFriends.dataArray removeObjectAtIndex:indexPath.section];
//    //            [tableCircleFriends.dataArray insertObject:[resData objectForJSONKey:@"data"] atIndex:indexPath.section];
//    //            [tableCircleFriends reloadData];
//    //
//    //        }else{
//    //            [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
//    //        }
//    //    }];
//    
//}
//-(void)deleteMessage:(MessageCircleFriendsTableViewCell *)sview object:(id)dic index:(NSIndexPath *)indexPath{
//    [self.view endEditing:YES];
//    //朋友圈删除
//    circleFriendsIndexPath=indexPath;
//    NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
//    [dict setValue:[[Utility Share] userId] forKey:@"uid"];
//    [dict setValue:[[Utility Share] userToken] forKey:@"token"];
//    [dict setValue:[dic valueForJSONStrKey:@"id"] forKey:@"id"];
//    [dict setValue:[dic valueForJSONStrKey:@"type"] forKey:@"type"];
//    [dict setValue:[self.otherInfo valueForJSONStrKey:@"id"] forKey:@"lid"];//    牌照id
//
//
//    [NetEngine createPostAction:XKFV3homesdelprocomt withParams:dict onCompletion:^(id resData, BOOL isCache) {
//        if ([[resData objectForJSONKey:@"status"] isEqualToString:@"200"]) {
//            [tableViewLeft.dataArray removeObjectAtIndex:indexPath.section];
//             [tableViewLeft reloadData];
//            [SVProgressHUD showSuccessWithStatus:@"删除成功!"];
//            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//
//            });
//
//
//        }else{
//            [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
//        }
//    }];
//    
//}
//-(void)selectImages:(MessageCircleFriendsTableViewCell *)sview{
//    [self.view endEditing:YES];
//}
//
//#pragma mark MessageEvaluationTableViewCellDelegate
//-(void)selectContent:(MessageEvaluationTableViewCell *)sview object:(id)dic index:(NSIndexPath *)indexPath{
//    //回复评论
//    circleFriendsIndexPath=indexPath;
//    if ([[dic valueForJSONStrKey:@"uid"] isEqual:[[Utility Share] userId]]) {
//        UIAlertView *aletv = [[UIAlertView alloc]initWithTitle:@"提示" message:@"是否要删除这条评论" delegate:self cancelButtonTitle:@"删除" otherButtonTitles:@"还是留着吧", nil];
//        aletv.tag = 101;
//        [aletv show];
//    }
//    else
//    {
//        
//        textKeyboard.textSend.placeholder=[NSString stringWithFormat:@"回复 %@ :",[dic valueForJSONStrKey:@"realnamea"]];
//        
//        __weak LicensePlateContentViewController * viewC2=self;
//        [textKeyboard setValueForDictionary:nil indexPath:circleFriendsIndexPath sendText:^(NSDictionary *dict, NSIndexPath *indexPath, NSString *txtSend) {
//            [viewC2 sendEvaluationData:txtSend selectIndex:indexPath];
//            
//        }];
//        
//    }
//    
//    
//}
//-(void)selectOneUser:(MessageEvaluationTableViewCell *)sview object:(id)dic index:(NSIndexPath *)indexPath{
//    [self selectContent:sview object:dic index:indexPath];
//}
//-(void)selectTwoUser:(MessageEvaluationTableViewCell *)sview object:(id)dic index:(NSIndexPath *)indexPath{
//    [self selectContent:sview object:dic index:indexPath];
//}
//-(void)sendEvaluationData:(NSString *)txtSend selectIndex:(NSIndexPath *)indexPath{
//    if (![txtSend notEmptyOrNull]) {
//        return;
//    }
//    krequestParam
//    [dictparam setValue:[self.otherInfo valueForJSONStrKey:@"id"] forKey:@"lid"];//    牌照id
//    [dictparam setValue:txtSend forKey:@"content"];
//    if (indexPath) {
//        NSDictionary *dicT=[tableViewLeft.dataArray objectAtIndex:indexPath.section];
//        [dictparam setValue:[dicT valueForJSONStrKey:@"id"] forKey:@"id"];
//        if (indexPath.row==0) {
//            [dictparam setValue:[dicT valueForJSONStrKey:@"uid"] forKey:@"backpid"];
//            [dictparam setValue:[dicT valueForJSONStrKey:@"type"] forKey:@"type"];
//        }else{
//            NSDictionary *dt=[[dicT objectForJSONKey:@"comment"] objectAtIndex:indexPath.row-1];
//            [dictparam setValue:[dt valueForJSONStrKey:@"uid"] forKey:@"backpid"];
//        }
//    }
//    
//    
//    [NetEngine createPostAction:XKFV3homespushcomment withParams:dictparam onCompletion:^(id resData, BOOL isCache) {
//        if ([[resData objectForJSONKey:@"status"] isEqualToString:@"200"]) {
//            textKeyboard.textSend.text=@"";
//            if (indexPath) {
//                NSDictionary *dicT=[tableViewLeft.dataArray objectAtIndex:indexPath.section];
//                NSMutableDictionary *dicUpdate=[[NSMutableDictionary alloc] initWithDictionary:dicT];
//                NSMutableArray *arrayUpdate=[[NSMutableArray alloc] initWithArray:[dicT objectForJSONKey:@"comment"]];
//                [arrayUpdate addObject:[resData objectForJSONKey:@"data"]];
//                [dicUpdate setValue:arrayUpdate forKey:@"comment"];
//                [tableViewLeft.dataArray replaceObjectAtIndex:indexPath.section withObject:dicUpdate];
//                [tableViewLeft reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
//            }else{
//                [tableViewLeft.dataArray insertObject:[resData objectForJSONKey:@"data"] atIndex:0];
//                [tableViewLeft reloadData];
//            }
//           
//        }else{
//            [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
//        }
//    }];
//}
//-(void)selectUserIcon:(MessageCircleFriendsTableViewCell *)sview object:(NSDictionary *)dic index:(NSIndexPath *)indexPath{
//    NSMutableDictionary *dicCard=[[NSMutableDictionary alloc] initWithDictionary:dic];
//    [dicCard setValue:[dic valueForJSONStrKey:@"card"] forKey:@"url"];
//    [dicCard setValue:[dic valueForJSONStrKey:@"uid"] forKey:@"uid"];
//    [dicCard setValue:NSStringFromClass([self class]) forKey:@"controller"];
//    [self pushController:[SelectWebUrlViewController class] withInfo:@"shareCard" withTitle:@" " withOther:dicCard];
//}
//#pragma mark UIAlertViewDelegate
//-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
//    if (alertView.tag==101 && buttonIndex==0) {
//        //删除
//        NSDictionary *dicT=[tableViewLeft.dataArray objectAtIndex:circleFriendsIndexPath.section];
//        if (circleFriendsIndexPath.row==0) {
//        }else{
//            NSDictionary *dt=[[dicT objectForJSONKey:@"comment"] objectAtIndex:circleFriendsIndexPath.row-1];
//            krequestParam
//            [dictparam setValue:[dt valueForJSONStrKey:@"id"] forKey:@"id"];
//            [dictparam setValue:[self.otherInfo valueForJSONStrKey:@"id"] forKey:@"lid"];//    牌照id
//            
//            [NetEngine createPostAction:XKFV3homesdelprocomt withParams:dictparam onCompletion:^(id resData, BOOL isCache) {
//                if ([[resData objectForJSONKey:@"status"] isEqualToString:@"200"]) {
//                    NSMutableDictionary *dicUpdate=[[NSMutableDictionary alloc] initWithDictionary:dicT];
//                    NSMutableArray *arrayUpdate=[[NSMutableArray alloc] initWithArray:[dicT objectForJSONKey:@"comment"]];
//                    [arrayUpdate removeObjectAtIndex:circleFriendsIndexPath.row-1];
//                    [dicUpdate setValue:arrayUpdate forKey:@"comment"];
//                    [tableViewLeft.dataArray replaceObjectAtIndex:circleFriendsIndexPath.section withObject:dicUpdate];
//                    [tableViewLeft reloadSections:[NSIndexSet indexSetWithIndex:circleFriendsIndexPath.section] withRowAnimation:UITableViewRowAnimationNone];
//                }else{
//                    [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
//                }
//            }];
//        }
//    }
//}
//
//#pragma mark selector
//-(void)handleKeyboardDidShow:(NSNotification *)notification{
//    NSDictionary *info = [notification userInfo];
//    CGRect keyboardFrame;
//    [[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardFrame];
//    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
//    CGFloat distanceToMove = kbSize.height;
//    DLog(@"---->动态键盘高度:%f",distanceToMove);
//    f_tempKeyBoard=distanceToMove+10;
//    float fy=0;
//    if (circleFriendsIndexPath) {
//        UITableViewCell *cell=[tableViewLeft cellForRowAtIndexPath:circleFriendsIndexPath];
//        fy=cell.frameYH-(H(tableViewLeft)-distanceToMove-10);
//    }else{
//        fy=H(viewHeaderBG)-(H(tableViewLeft)-distanceToMove-10);
//    }
//   
//    fy=fy<0?0:fy;
//    [tableViewLeft setContentOffset:CGPointMake(0, fy)];
//}
//
//- (void)handleKeyboardWillHide:(NSNotification *)notification
//{
//    float ftmp=0;
//    if (circleFriendsIndexPath) {
//        UITableViewCell *cell=[tableViewLeft cellForRowAtIndexPath:circleFriendsIndexPath];
//        ftmp=cell.frameYH;
//    }else{
//        ftmp=H(viewHeaderBG);
//    }
//    if (ftmp+f_tempKeyBoard>tableViewLeft.contentSize.height) {
//        float fy=tableViewLeft.contentSize.height-H(tableViewLeft);
//        fy=fy<0?0:fy;
//        [tableViewLeft setContentOffset:CGPointMake(0, fy)];
//    }
//}////
//
//
-(void)backRefreshData{
    for (id controller in self.navigationController.viewControllers) {
        if ([NSStringFromClass([controller class]) isEqualToString:@"LicensePlateViewController"]||
            [NSStringFromClass([controller class]) isEqualToString:@"UserLicensePlateViewController" ]||
            [NSStringFromClass([controller class]) isEqualToString:@"UserExtensionViewController" ]||
            [NSStringFromClass([controller class]) isEqualToString:@"V4HomeViewController" ]) {
            if ([(NSObject*)controller respondsToSelector:@selector(popRefreshData)]) {
                [controller performSelector:@selector(popRefreshData) withObject:nil afterDelay:0.01];
            }
            continue;
        }
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
